<template>
  <div class="myroles">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 列表 -->
    <el-table
      :data="rightsList"
      stripe
      style="width: 100%">
      <el-table-column
        type="index"
        label="编号"
        width="50">
      </el-table-column>
      <el-table-column
        prop="authName"
        label="权限名称">
      </el-table-column>
      <el-table-column
        prop="path"
        label="路径">
      </el-table-column>
      <el-table-column
        label="层级">
        <template slot-scope="scope">
          <el-tag>{{scope.row.level | fmtLevel}}</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {rightList} from '@/api'
export default {
  data () {
    return {
      rightsList: []
    }
  },
  methods: {
    renderList () {
      rightList('list')
        .then(res => {
          // console.log(res)
          if (res.meta.status === 200) {
            this.rightsList = res.data
          }
        })
    }
  },
  filters: {
    fmtLevel (level) {
      if (level === '0') {
        return '一级'
      } else if (level === '1') {
        return '二级'
      } else {
        return '三级'
      }
    }
  },
  created () {
    this.renderList()
  }
}
</script>

<style lang="scss" scoped>

</style>
